<?php
/**
 * Created by Engineer CuiLiwu.
 * Project: deal.
 * Date: 2018/6/22-16:24
 * License Hangzhou orce Technology Co., Ltd. Copyright © 2018
 */

namespace App\Http\Controllers\Web\Member\Seller;

use App\Http\Controllers\Web\BaseController;
use Illuminate\Http\Request;

// 找资质，服务订单。商家管理控制器。
class ServiceOrdersController  extends BaseController
{
    protected $api_url = [
        'index' => ['get',  'seller/service/orders'],
        'show'  => ['get',  'seller/service/orders/%d'],
        'store' => ['post', 'seller/service/orders'],
        'update'=> ['put',  'seller/service/orders/%d'],
        // 'delete'=> ['delete', ''],
    ];

    protected $request;

    public function __construct(Request $request)
    {
        $this->request = $request;
    }
    
    public function index(){

        //参数部分
        $search_params = $this->request->all(['order_code', 'created_at','status','keyword']);
        $page = $this->request->get('page', 1);
        $params = [
            'search' => search_params($search_params),
            'searchJoin' => 'and',
            'page' => $page,
            'with' => 'orderProducts;user;shop;order_qualification',
            'orderBy'=>'id',
            'sortedBy'=>'desc',
        ];
        //请求部分
        $ret = http_web($this->api_url['index'])->send($params);

        //结果处理部分
        $data = paginate($this->request, $ret['data']);

        //回填搜索框值
        $data['search_params'] = $search_params;

        return view('web.user.seller.service_orders', $data);
    }

}